package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.common.VMSystem;
import com.lkd.config.TopicConfig;
import com.lkd.contract.VendoutContract;
import com.lkd.contract.VmStatusContract;
import com.lkd.emq.Topic;
import com.lkd.entity.OrderEntity;
import com.lkd.service.VendingMachineService;
import com.lkd.utils.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author : Bing
 * @Date 2023/3/2 18:52
 */
@Component
@Topic(TopicConfig.VMS_STATUS_TOPIC)
public class ShipmentMsgHandler implements MsgHandler {

    @Autowired
    private VendingMachineService vendingMachineService;

    @Override
    public void process(String jsonMsg) throws IOException {

        //解析消息
        VendoutContract vendoutContract = JsonUtil.getByJson(jsonMsg, VendoutContract.class);

        //2.库存扣减
        vendingMachineService.vendOut(vendoutContract);


    }

}
